import { http } from '@/utils/request'
import type { MenuType, MenuTypeWriteParamsType } from './model'

/**
 * 获取菜单权限列表
 * @returns MenuType[]
 */
export const getMenuPermsListAPI = () => {
  return http.request<MenuType[]>('get', '/sys_menu/perms')
}

/**
 * 获取菜单列表
 * @returns MenuType[]
 */

export const getMenuListAPI = () => {
  return http.request<MenuType[]>('get', '/sys_menu/menu')
}

/**
 * 新增菜单
 * @param data
 * @returns
 */
export const addMenuAPI = (data: MenuTypeWriteParamsType) => {
  return http.request('post', '/sys_menu', { data })
}

/**
 * 修改菜单
 * @param id
 * @param data
 * @returns
 */
export const updateMenuAPI = (id: number, data: MenuTypeWriteParamsType) => {
  return http.request('put', `/sys_menu/${id}`, { data })
}

/**
 * 删除菜单
 * @param id
 * @returns
 */
export const deleteMenuAPI = (id: number) => {
  return http.request('delete', `/sys_menu/${id}`)
}
